package org.easyway.tiles.generic;

public class ZoomManager {
	protected static GraphicBoard board;

	private static float zoomFactor = 1;

	private final static float ZOOM_VALUE = 0.1f;

	public static float getZoomFactor() {
		return zoomFactor;
	}

	public static void setZoomFactor(float zoomFactor) {
		ZoomManager.zoomFactor = zoomFactor;
		
		board
				.setSize(
						(int) (GraphicBoard.worldWidth * (GraphicBoard.tileWidth / zoomFactor)),
						(int) (GraphicBoard.worldHeight * (GraphicBoard.tileHeight / zoomFactor)));
		board.setPreferredSize(board.getSize());
		//board.scroll.setViewportView(null);
		//board.scroll.setViewportView(board);
		board.scroll.validate();
		board.scroll.repaint();
	}

	public static void incZoomFactor() {
		incZoomFactor(ZOOM_VALUE);
	}

	public static void decZoomFactor() {
		decZoomFactor(ZOOM_VALUE);
	}

	public static void incZoomFactor(float zoomFactor) {
		setZoomFactor(ZoomManager.zoomFactor + zoomFactor);
	}

	public static void decZoomFactor(float zoomFactor) {
		setZoomFactor(ZoomManager.zoomFactor - zoomFactor);
	}

}

